import java.util.*;

public class Test {
    public static void main(String[] args) {
        Queue<Integer> queue =new LinkedList<>();
        Deque<Integer> queue2 =new LinkedList<>();//用链表实现双端队列
        Deque<Integer> queue3 =new ArrayDeque<>();//底层为数组的双端队列
    }
    public static void main5(String[] args) {
        MyQueue queue =new MyQueue();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        queue.offer(5);
        queue.poll();
        queue.poll();
        queue.poll();
        queue.poll();
        //queue.poll();
        System.out.println(queue.poll());
        System.out.println(queue.peek());
    }
    public static void main4(String[] args) {
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        System.out.println(queue.poll());
        System.out.println(queue.peek());

    }
    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for(int i = 0;i<s.length();i++){
            char ch = s.charAt(i);
            if(ch == '(' || ch== '[' || ch == '{'){
                stack.push(ch);
            }else{
                if(stack.isEmpty()){
                    return false;
                }
                char ch2 = stack.peek();
                if(ch==')'&&ch2=='('||ch=='}'&&ch2=='{'||ch==']'&&ch2=='['){
                    stack.pop();
                }else{
                    return false;
                }
            }
        }
        if(!stack.isEmpty()){
            return false;
        }else{
            return true;
        }
    }
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for(int i = 0; i<tokens.length;i++){
            if(!isOperator(tokens[i])){
                int x = Integer.parseInt(tokens[i]);
                stack.push(x);
            }else{
                int val2 = stack.pop();
                int val1 = stack.pop();
                switch(tokens[i]){
                    case "+":
                        stack.push(val1+val2);
                        break;
                    case "-":
                        stack.push(val1-val2);
                        break;
                    case "*":
                        stack.push(val1*val2);
                        break;
                    case "/":
                        stack.push(val1/val2);
                        break;
                }
            }
        }
        return stack.peek();
    }
    private boolean isOperator(String ch){
        if(ch.equals("+")||ch.equals("-")||ch.equals("*")||ch.equals("/")){
            return true;
        }
        return false;
    }
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for(int i = 0; i < popV.length;i++){
            stack.push(pushV[i]);
            while(!stack.empty() && j < popV.length &&
                    stack.peek() == popV[j]){
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
    public static void main3(String[] args) {
        LinkedList<Integer> stack = new LinkedList<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);
        stack.push(45);
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.peek());
    }
    public static void main2(String[] args) {
        MyStack stack = new MyStack();
        stack.push(12);
        stack.push(23);
        stack.push(34);
        stack.push(45);
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.peek());

    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);
        stack.push(45);
        System.out.println(stack.pop());
        System.out.println(stack.peek());
    }
}
